package util;

import java.io.PrintStream;
import java.util.Date;

public class Log {

    public static void i(String tag, String message) {
        i(tag, message, null);
    }

    public static void i(String tag, String message, Throwable t) {
        logger("I", tag, message, t);
    }

    public static void e(String tag, String message) {
        e(tag, message, null);
    }

    public static void e(String tag, String message, Throwable t) {
        logger("E", tag, message, t);
    }

    private static PrintStream out = System.out;

    private static void logger(String category, String tag, String message, Throwable t) {
        StringBuilder sb = new StringBuilder();
        sb.append(">>>");

        sb.append(new Date());
        sb.append(" ").append(category).append("/");
        sb.append(tag).append(": ");
        sb.append(message);
        out.println(sb);
        if (t != null)
            t.printStackTrace(out);
    }

}
